Skip to content

Pass empty values to Csv post-processors for None input - #188

Closed
Eric3-jp wants to merge 1 commit into
HBNetwork:masterfrom
Eric3-jp:fix-csv-none-post-process
Closed

Eric3-jp wants to merge 1 commit into
HBNetwork:masterfrom
Eric3-jp:fix-csv-none-post-process

Conversation

@Eric3-jp

Copy link
Copy Markdown

Csv normally passes an iterator of cast values to post_process, but its None branch calls the same function without an argument. As a result, Csv(cast=int, post_process=sum)(None) raises TypeError while the equivalent empty-string input returns 0. A custom post-processor with a required argument also fails when used with Config(..., default=None).

Normalize None to an empty string and reuse the existing parsing path. This supplies an empty iterator to the post-processor without calling the item cast, and preserves the empty list/tuple results.

The regressions cover None and empty-string input with list, tuple, sum, and sorted, plus a custom iterator-consuming post-processor through Config(default=None). Before the fix, three regressions failed and nine CSV tests passed.

Validation:

  • Python 3.10.21: all 76 tests passed.
  • Python 3.12.3: all 76 tests passed; 97% coverage.
  • PyPy 2.7.18 with the project's pinned pytest/mock versions: 74 passed, including all CSV regressions. Two existing mock_open encoding tests failed identically in an untouched baseline checkout.
  • Source/test byte compilation and git diff --check: passed.
  • Wheel/sdist build and twine check: passed, with the existing warning about missing long_description_content_type.

This issue was identified during source review. The implementation and tests were prepared with OpenAI Codex assistance.

@Eric3-jp Eric3-jp closed this by deleting the head repository Sep 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant